import { createElement, HTMLAttributes, type FC } from 'react';
import classNames from 'classnames';

import { commentMetadataDefaultProps } from './defaultProps';
import type { CommentMetadataOptions } from './type';

export interface CommentMetadataProps extends CommentMetadataOptions, HTMLAttributes<HTMLDivElement> {}

const CommentMetadata: FC<CommentMetadataProps> = (props) => {
  const { className, children, forwardedRef, ...commentMetadataProps } = props;

  return createElement(
    'div',
    { ref: forwardedRef, className: classNames('metadata', className), ...commentMetadataProps },
    children,
  );
};

CommentMetadata.displayName = 'CommentMetadata';
CommentMetadata.defaultProps = commentMetadataDefaultProps;

export default CommentMetadata;
